package dst1.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class ComputerCPUConstraintValidator implements ConstraintValidator<CPU, Integer> {
	int min;
	int max;
	
	@Override
	public void initialize(CPU arg0) {
		min = arg0.min();
		max = arg0.max();
	}

	@Override
	public boolean isValid(Integer arg0, ConstraintValidatorContext arg1) {
		if (arg0 == null) {
	         return false;
	    }
		
		if(arg0 >= min && arg0 <= max)
			return true;
		
		return false;
	}
	
}
